
package edu.gu.hajo.gcl.cmd.impl;

import edu.gu.hajo.gcl.exception.ExecException;
import edu.gu.hajo.gcl.interp.IInterpreter;

/**
 * The + command
 * @author hajo
 *
 */
public final class AddOpCmd extends AbstractCmd {

	public AddOpCmd(IInterpreter interp) {
		super(interp);
	} 

	@Override
	public void  execute() {	
		if( args == null){
			throw new ExecException("AddOpCmd args null");
		}
		if( args.size() != 2){
			throw new ExecException("AddOpCmd # args" + args);
		}
		int result = Integer.parseInt(args.get(0)) + Integer.parseInt(args.get(1));
		interp.setResult(String.valueOf(result));
	}
}
